package com.gopay.bis.dao.payconfig.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.bis.dao.payconfig.BisBizProdSpBankConfigDAO;
import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.bis.BisBizProdSpBankConfig;

/**
 * 
 * @author liujy
 *
 */
@Repository("bisBizProdSpBankConfigDAO")
public class BisBizProdSpBankConfigDAOImpl extends BaseDAOImpl<BisBizProdSpBankConfig, String>
	implements BisBizProdSpBankConfigDAO{
	
	public List<BisBizProdSpBankConfig> findConfigsByBankBizProds(List<String> prods){
		if(null == prods || prods.isEmpty()){
			return null;
		}
		String hql = "from BisBizProdSpBankConfig where bankBizProdCode in (:prods) and b.enable=:enable";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("prods", prods);
		param.put("enable", true);
		return findByHql(hql, param);
	}

	@Override
	public List<BisBizProdSpBankConfig> findAll() {
		StringBuilder s = new StringBuilder("from BisBizProdSpBankConfig b where 1 = 1 and b.enable=:enable");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

	/**
	 * 获取B2C网关产品银行配置信息
	 */
	public List<BisBizProdSpBankConfig> findEbankB2c() {
		StringBuilder s = new StringBuilder("select b from BisBizProdSpBankConfig b,BisEbankB2CConfig a where 1 = 1 and b.enable=:enable and a.enable=:enable and b.bankCode=a.bankCode order by a.priorityNum");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

	/**
	 * 获取B2B网关产品银行配置信息
	 */
	public List<BisBizProdSpBankConfig> findEbankB2b() {
		StringBuilder s = new StringBuilder("select b from BisBizProdSpBankConfig b,BisEbankB2BConfig a where 1 = 1 and b.enable=:enable and a.enable=:enable and b.bankCode=a.bankCode order by a.priorityNum");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

	/**
	 * 获取快捷产品银行配置信息
	 */
	public List<BisBizProdSpBankConfig> findMotopay() {
		StringBuilder s = new StringBuilder("select b from BisBizProdSpBankConfig b,BisMotoPayConfig a where 1 = 1 and b.enable=:enable and a.enable=:enable and b.bankCode=a.bankCode order by a.priorityNum");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

	/**
	 * 获取信用卡快捷产品银行配置信息
	 */
	public List<BisBizProdSpBankConfig> findCreditExpay() {
		StringBuilder s = new StringBuilder("select b from BisBizProdSpBankConfig b,BisCreditExPayConfig a where 1 = 1 and b.enable=:enable and a.enable=:enable and b.bankCode=a.bankCode order by a.priorityNum");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}

	/**
	 * 获取借记卡快捷产品银行配置信息
	 */
	public List<BisBizProdSpBankConfig> findDebitExpay() {
		StringBuilder s = new StringBuilder("select b from BisBizProdSpBankConfig b,BisDebitExPayConfig a where 1 = 1 and b.enable=:enable and a.enable=:enable and b.bankCode=a.bankCode order by a.priorityNum");
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("enable", true);
		
		return findByHql(s.toString(), param);
	}
}
